﻿using System;
using System.IO;
using System.Text;
using Manager;

// Token: 0x020002D1 RID: 721
[Serializable]
public class CharFileInfoPreview : global::BlockControlBase
{
	// Token: 0x06001172 RID: 4466 RVA: 0x0008DD7C File Offset: 0x0008BF7C
	public CharFileInfoPreview() : base("プレビュー情報", 4)
	{
	}

	// Token: 0x06001173 RID: 4467 RVA: 0x0008DDA0 File Offset: 0x0008BFA0
	public override byte[] SaveBytes()
	{
		byte[] result;
		using (MemoryStream memoryStream = new MemoryStream())
		{
			using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
			{
				binaryWriter.Write(11);
				binaryWriter.Write(this.sex);
				binaryWriter.Write(this.personality);
				int byteCount = Encoding.UTF8.GetByteCount(this.name);
				binaryWriter.Write(byteCount);
				binaryWriter.Write(this.name);
				binaryWriter.Write(this.height);
				binaryWriter.Write(this.bustSize);
				binaryWriter.Write(this.hairType);
				binaryWriter.Write(this.state);
				binaryWriter.Write(this.resistH);
				binaryWriter.Write(this.resistPain);
				binaryWriter.Write(this.resistAnal);
				binaryWriter.Write(this.isConcierge);
				result = memoryStream.ToArray();
			}
		}
		return result;
	}

	// Token: 0x06001174 RID: 4468 RVA: 0x0008DEAC File Offset: 0x0008C0AC
	public override bool LoadBytes(byte[] data, int previewVer)
	{
		bool result;
		using (MemoryStream memoryStream = new MemoryStream(data))
		{
			using (BinaryReader binaryReader = new BinaryReader(memoryStream))
			{
				if (4 <= previewVer)
				{
					this.productNo = binaryReader.ReadInt32();
				}
				this.sex = binaryReader.ReadInt32();
				if (2 <= previewVer)
				{
					this.personality = binaryReader.ReadInt32();
					if (global::Singleton<Manager.Character>.IsInstance() && !global::Singleton<Manager.Character>.Instance.charaListInfo.IsPersonality(this.personality))
					{
						this.personality = 0;
					}
					int num = binaryReader.ReadInt32();
					this.name = binaryReader.ReadString();
					this.height = binaryReader.ReadInt32();
					this.bustSize = binaryReader.ReadInt32();
					this.hairType = binaryReader.ReadInt32();
				}
				if (4 <= previewVer)
				{
					this.state = binaryReader.ReadInt32();
					this.resistH = binaryReader.ReadInt32();
					this.resistPain = binaryReader.ReadInt32();
					this.resistAnal = binaryReader.ReadInt32();
				}
				if (3 <= previewVer)
				{
					this.isConcierge = binaryReader.ReadInt32();
				}
				result = true;
			}
		}
		return result;
	}

	// Token: 0x06001175 RID: 4469 RVA: 0x0008E008 File Offset: 0x0008C208
	public virtual void Update(global::CharFile chaFile)
	{
		this.sex = (int)chaFile.customInfo.sex;
		this.name = chaFile.customInfo.name;
		this.isConcierge = ((!chaFile.customInfo.isConcierge) ? 0 : 1);
		if (this.sex == 0)
		{
			this.personality = 255;
			this.height = 255;
			this.bustSize = 255;
			this.hairType = 255;
			this.state = 255;
			this.resistH = 255;
			this.resistPain = 255;
			this.resistAnal = 255;
		}
		else
		{
			this.personality = chaFile.customInfo.personality;
			float num = chaFile.customInfo.shapeValueBody[0];
			if (num < 0.33f)
			{
				this.height = 0;
			}
			else if (num > 0.66f)
			{
				this.height = 2;
			}
			else
			{
				this.height = 1;
			}
			float num2 = chaFile.customInfo.shapeValueBody[1];
			if (num2 < 0.33f)
			{
				this.bustSize = 0;
			}
			else if (num2 > 0.66f)
			{
				this.bustSize = 2;
			}
			else
			{
				this.bustSize = 1;
			}
			this.hairType = chaFile.customInfo.hairType;
			global::CharFileInfoParameterFemale charFileInfoParameterFemale = chaFile.parameterInfo as global::CharFileInfoParameterFemale;
			this.state = (int)charFileInfoParameterFemale.nowState;
			this.resistH = ((charFileInfoParameterFemale.resistH != 100) ? 0 : 1);
			this.resistPain = ((charFileInfoParameterFemale.resistPain != 100) ? 0 : 1);
			this.resistAnal = ((charFileInfoParameterFemale.resistAnal != 100) ? 0 : 1);
		}
	}

	// Token: 0x04001777 RID: 6007
	public int previewLoadVersion;

	// Token: 0x04001778 RID: 6008
	public int productNo = 11;

	// Token: 0x04001779 RID: 6009
	public int sex;

	// Token: 0x0400177A RID: 6010
	public int personality;

	// Token: 0x0400177B RID: 6011
	public string name = string.Empty;

	// Token: 0x0400177C RID: 6012
	public int height;

	// Token: 0x0400177D RID: 6013
	public int bustSize;

	// Token: 0x0400177E RID: 6014
	public int hairType;

	// Token: 0x0400177F RID: 6015
	public int state;

	// Token: 0x04001780 RID: 6016
	public int resistH;

	// Token: 0x04001781 RID: 6017
	public int resistPain;

	// Token: 0x04001782 RID: 6018
	public int resistAnal;

	// Token: 0x04001783 RID: 6019
	public int isConcierge;
}
